//
//  TJFriendsListCell.m
//  Teleport
//
//  Created by xtjun on 2020/6/13.
//  Copyright © 2020 xtjun. All rights reserved.
//

#import "TJFriendsListCell.h"

@interface TJFriendsListCell()

@property (weak, nonatomic) UILabel *tj_textLabel;
@property (weak, nonatomic) UIImageView *iconImageView;


@end

@implementation TJFriendsListCell

- (void)settingSubView {
    
    UIImageView *iconImageView = [UIImageView tj_addToView:self.contentView];
    [iconImageView shearRoundedCornersWithRadiu:20];
    iconImageView.backgroundColor = UIColor_Hex(0xf2f2f2);
    [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(16);
        make.centerY.offset(0);
        make.width.height.offset(40);
    }];
    
    UILabel *tj_textLabel = [UILabel lableWithSuperView:self.contentView font:UIFont_Px(16) color:UIColor.blackColor title:@"" textAlignment:NSTextAlignmentLeft];
    [tj_textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(iconImageView.mas_right).offset(16);
        make.centerY.offset(0);
    }];
    
    UILabel *transferLabel = [UILabel lableWithSuperView:self.contentView font:UIFont_Px(14) color:UIColor.whiteColor title:@"转账".localizedString textAlignment:NSTextAlignmentCenter];
    [transferLabel shearRoundedCornersWithRadiu:3];
    transferLabel.backgroundColor = UIColor_Hex(0x3781E7);
    [transferLabel addTapGesturesWithTarget:self action:@selector(tapTransferLabel)];
    [transferLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-16);
        make.width.offset(60);
        make.height.offset(28);
        make.centerY.offset(0);
    }];
    
    _iconImageView = iconImageView;
    _tj_textLabel = tj_textLabel;
    
}

- (void)tapTransferLabel {
    if (_tapTransferLabelBlock) {
        _tapTransferLabelBlock(_dict[@"userId"]);
    }
}

- (void)setDict:(NSDictionary *)dict {
    _dict = dict;
    
    [_iconImageView sd_setImageWithURL:[NSURL URLWithString:dict[@"imgUrl"]] placeholderImage:[UIImage imageNamed:defaultAvatarImageName]];
    _tj_textLabel.text = [NSString stringWithFormat:@"%@", dict[@"userId"]];
}

@end
